package edu.swust.graduation_project.eauction.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.google.android.material.bottomnavigation.BottomNavigationView
import edu.swust.graduation_project.eauction.R
import edu.swust.graduation_project.eauction.fragment.*

class DeliveryListActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_list_delivery)
        val mBnvDelivery = findViewById<BottomNavigationView>(R.id.bn_delivery)
        val mBuyerFragment=BuyerFragment()
        val mSellerFragment=SellerFragment()

        mBnvDelivery.setOnNavigationItemSelectedListener { item ->
            when (item.itemId) {
                R.id.navigation_buyer -> {
                    supportFragmentManager.beginTransaction()
                        .replace(R.id.fl_delivery, mBuyerFragment).commitAllowingStateLoss()
                }

                R.id.navigation_seller -> {
                    supportFragmentManager.beginTransaction()
                        .replace(R.id.fl_delivery, mSellerFragment).commitAllowingStateLoss()
                }
            }
            true
        }
        supportFragmentManager.beginTransaction().add(R.id.fl_delivery, mBuyerFragment)
            .commitAllowingStateLoss()

    }
}